package main

import (
	"fmt"
	"time"
)

func printMessage(message string, count int) {
	for i := 0; i < count; i++ {
		fmt.Printf("%s: %d\n", message, i)
		time.Sleep(100 * time.Millisecond)
	}
}

func sayHello() {
	fmt.Println("Hello from goroutine!")
}

func main() {
	// 启动一个 goroutine
	go sayHello()

	// 主线程等待，否则 goroutine 可能没机会执行
	time.Sleep(100 * time.Millisecond)
	fmt.Println("Hello from main!")

	// 启动多个带参数的 goroutine
	go printMessage("Goroutine 1", 3)
	go printMessage("Goroutine 2", 3)
	go printMessage("Goroutine 3", 3)

	time.Sleep(1 * time.Second)
	fmt.Println("Main function completed")
}
